﻿using System;
using System.Collections.Generic;
using System.Web;
using He.Web.UI;

namespace He.Web.tools
{
    /// <summary>
    /// attr_field 的摘要说明
    /// </summary>
    public class attr : AjaxHandler
    {

        public override void ProcessRequest(HttpContext context)
        {
            UI.Manage bk = new UI.Manage();
            if (!bk.IsAdminLogin())
            {
                EchoJson(0, "您还未登陆，请先登陆");
                return;
            }

            //取得事件类型
            string action = InputUtil.Get("action");

            switch (action)
            {
                //修改字表标题
                case "delAttrItem":
                    DelAttrItem(context);
                    break;
            }
        }

        public void DelAttrItem(HttpContext context)
        {
            BLL.attr_item bll = new BLL.attr_item();
            BLL.attr_value valuebll = new BLL.attr_value();

            int attrItemId = InputUtil.Get("attrItemId", 0);
            //判断是否被使用
            if (valuebll.ExistsByAttrItemId(attrItemId))
            {
                EchoJson(0, "该选项正在被使用，不可删除");
                return;
            }
            bll.Delete(attrItemId);
            EchoJson(1, "删除成功");
        }

        public override bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}